<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="renderer" content="webkit">
    <title><?php echo ($title); ?></title>
    <link rel="stylesheet" href="/Public/web/css/pintuer.css">
    <link rel="stylesheet" href="/Public/web/css/admin.css">
    <script src="/Public/web/js/jquery.js"></script>
    <script src="/Public/web/js/pintuer.js"></script>
</head>


<body>
  <form action="" id="listform">
    <div class="panel admin-panel">
      <div class="panel-head"><strong class="icon-reorder"> <?php echo L("shangpinliebiao");?></strong></div>
      <div class="padding border-bottom">
        <ul class="search" style="padding-left:10px;">
          <li> <a class="button border-main icon-plus-square-o" href="<?php echo U('goods/edit');?>"> <?php echo L("tianjia");?></a> </li>
          <li><?php echo L("sousuo");?>：</li>
          <!--<li>-->
            <!--<select name="goods_cate_id" class="input" style="width:200px; line-height:17px;" onchange="changesearch()">-->
              <!--<option value=""><?php echo L("qingxuanze");?></option>-->
              <!--<?php if(is_array($cate_list)): foreach($cate_list as $key=>$v): ?>-->
                <!--<option value="<?php echo ($v['goods_cate_id']); ?>" <?php if($v['goods_cate_id'] == $goods_cate_id): ?>selected="selected"<?php endif; ?>><?php echo ($v['goods_cate_name']); ?></option>-->
                <!--<?php if($v['sonlist']): ?>-->
                  <!--<?php if(is_array($v['sonlist'])): foreach($v['sonlist'] as $key=>$v2): ?>-->
                    <!--<option value="<?php echo ($v2['goods_cate_id']); ?>" <?php if($v2['goods_cate_id'] == $goods_cate_id): ?>selected="selected"<?php endif; ?>>-&#45;&#45;<?php echo ($v2['goods_cate_name']); ?></option>-->
                  <!--<?php endforeach; endif; ?>-->
                <!--<?php endif; ?>-->
              <!--<?php endforeach; endif; ?>-->
            <!--</select>-->
          <!--</li>-->
          <li>
            <input type="text" placeholder="<?php echo L('qingshuru'); echo L('shangpinmingcheng');?>" name="goods_name" value="<?php echo ($goods_name); ?>" class="input" style="width:250px; line-height:17px;display:inline-block" />
            <input type="submit" value="<?php echo L('sousuo');?>" class="button border-main icon-search"/>
          </li>
        </ul>
      </div>
      <table class="table table-hover text-center">
        <tr>
          <th width="100" style="text-align:center;"><?php echo L("xuanze");?></th>
          <th><?php echo L("shangpinmingcheng");?></th>
          <th><?php echo L("fenleibiaoti");?></th>
          <th width="10%"><?php echo L("tupian");?></th>
          <th><?php echo L("xianshi");?></th>
          <th><?php echo L("zhuye");?></th>
          <th><?php echo L("remen");?></th>
          <th width="10%"><?php echo L("paixu");?></th>
          <th width="10%"><?php echo L("gengxinshijian");?></th>
          <th width="310"><?php echo L("caozuo");?></th>
        </tr>
        <?php if(is_array($list)): foreach($list as $key=>$v): ?><tr class="tr<?php echo ($v['goods_id']); ?>">
            <td style="text-align:center;">
              <input type="checkbox" name="id[]" value="<?php echo ($v['goods_id']); ?>" />
            </td>
            <td><?php echo ($v['goods_name']); ?></td>
            <td><?php echo ($v['goods_cate_name']); ?></td>
            <td><img src="/<?php echo ($v['default_img']); ?>" alt="" width="70" /></td>
            <td><span class="sp01" onclick="is_show(<?php echo ($v['goods_id']); ?>,this)">
              <?php if($v['is_show'] == 1): ?><img src="/Public/web/images/yes.png" width="18px;" alt="">
                <?php else: ?>
                <img src="/Public/web/images/no.png" width="18px;" alt=""><?php endif; ?>
            </span></td>
            <td><span class="sp01" onclick="is_home(<?php echo ($v['goods_id']); ?>,this)">
              <?php if($v['is_home'] == 1): ?><img src="/Public/web/images/yes.png" width="18px;" alt="">
                <?php else: ?>
                <img src="/Public/web/images/no.png" width="18px;" alt=""><?php endif; ?>
            </span></td>
            <td><span class="sp01" onclick="is_hot(<?php echo ($v['goods_id']); ?>,this)">
              <?php if($v['is_hot'] == 1): ?><img src="/Public/web/images/yes.png" width="18px;" alt="">
                <?php else: ?>
                <img src="/Public/web/images/no.png" width="18px;" alt=""><?php endif; ?>
            </span></td>
            <td><?php echo ($v['sort']); ?></td>
            <td><?php echo (date("Y-m-d H:i",$v['add_time'])); ?></td>
            <td>
              <div class="button-group">
                <a class="button border-main" href="<?php echo U('goods/edit',array('id'=>$v['goods_id']));?>"><span class="icon-edit"></span> <?php echo L("bianji");?></a>
                <a class="button border-red" href="javascript:void(0)" onclick="return del(<?php echo ($v['goods_id']); ?>)"><span class="icon-trash-o"></span> <?php echo L("shanchu");?></a>
              </div>
            </td>
          </tr><?php endforeach; endif; ?>
        <tr>
          <td colspan="10" align="left">
            <span class="maodian"></span>
            <a id="checkall" class="button border-main" href="javascript:void(0)"><?php echo L("quanxuan");?></a>
            <a class="button border-red" href="javascript:void(0)" onclick="return DelSelect()"><?php echo L("shanchu");?></a>
          </td>
          <td colspan="10"><div class="pagelist"><?php echo ($page); ?></div></td>
        </tr>
      </table>
    </div>
  </form>
  <script type="text/javascript">
//单个删除
function del(id){
  if(confirm("<?php echo L('shanchuxiaoxi');?>")){
    var url = "<?php echo U('goods/delete');?>";
    $.getJSON(url,{id:id},function (data){
      if(data.result == 'tp'){$(".tr"+id).remove();}
      else if(data.result == 'break'){alert('ERROR.');}
    })
  }
}
function is_show(id,t){
  var url = "<?php echo U('goods/is_show');?>";
  $.getJSON(url,{id:id},function (data){
    if(data.result == 'yes'){
      $(t).find('img').attr('src',"/Public/web/images/yes.png");
    }else if(data.result == 'no'){
      $(t).find('img').attr('src',"/Public/web/images/no.png");
    }
  })
}
function is_home(id,t){
  var url = "<?php echo U('goods/is_home');?>";
  $.getJSON(url,{id:id},function (data){
    if(data.result == 'yes'){
      $(t).find('img').attr('src',"/Public/web/images/yes.png");
    }else if(data.result == 'no'){
      $(t).find('img').attr('src',"/Public/web/images/no.png");
    }
  })
}
function is_hot(id,t){
  var url = "<?php echo U('goods/is_hot');?>";
  $.getJSON(url,{id:id},function (data){
    if(data.result == 'yes'){
      $(t).find('img').attr('src',"/Public/web/images/yes.png");
    }else if(data.result == 'no'){
      $(t).find('img').attr('src',"/Public/web/images/no.png");
    }
  })
}
//全选
$("#checkall").click(function(){ 
  $("input[name='id[]']").each(function(){
   if (this.checked) {
    this.checked = false;
  }
  else {
    this.checked = true;
  }
});
})
//批量删除
function DelSelect(){
	var Checkbox=false;
  $("input[name='id[]']").each(function(){
   if (this.checked==true) {		
    Checkbox=true;	
  }
});
  if (Checkbox){
    var t=confirm("<?php echo L('shanchuxiaoxi');?>");
    if(t==false){
      return false;
    }else{
      $(".maodian").html("<input type='hidden' value='x' name='maodian' />");
      $("#listform").submit();
    }	
  }
  else{
    alert("None!");
    return false;
  }
}
</script>
</body>

</html>